{extend name="public:base"/}


{block name="title"}编辑分类{/block}

{block name="style"}
<link href="__STATIC__/admin/plugin/my_uploader/css/uploads.css" rel="stylesheet">
{/block}

{block name="main"}

<section class="content" xmlns="http://www.w3.org/1999/html">
    <div class="row">

        <div class="col-md-12">

            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">编辑分类</h3>
                        </div>
                        <form  id="pt_form" method="post">
                            <div class="box-body">

                                <input type="hidden" name="id" value="<?=$model['id']?>" ?>
                                <div class="clearfix"></div>

     
                                <div class="form-group required">
                                    <div class='col-sm-2 text-right'>
                                        <label for="name" class="control-label Validform_label" >分类名称</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="text" id="name" class="form-control" name="name" placeholder="请输入分类名称" value="<?=$model['name']?>" datatype="s2-90" ignore="ignore"  nullmsg="请填写分类名称">
                                        <div class="help-block"></div>
                                    </div>
                                </div>
          
                                <div class="form-group required" >
                                    <div class='col-sm-2 text-right'>
                                        <label class="control-label" for="parent_id">上级分类</label>
                                    </div>
                                    <div class='col-sm-10'>

                                        <select id="parent_id" class="form-control" name="parent_id">
                                            <option value="0">顶级分类</option>
                                            <?php if(!empty($categoryList)){foreach($categoryList as $k=>$v){?>
                                            <option <?=$v['id'] == $model['parent_id']?'selected="selected"':''?> value="<?=$v['id']?>"><?=str_repeat('|------',$v['lev'])?><?=$v['name']?></option>
                                            <?php }} ?>
                                        </select>
                                        <div class="help-block"></div>
                                    </div>
                                </div>
     
                                <div class="form-group ">
                                    <div class='col-sm-2 text-right'>
                                        <label for="sort_order" class="control-label Validform_label" >排序</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <input type="text" id="sort_order" class="form-control" name="sort_order" placeholder="请输入排序数字" value="<?=$model['sort_order']?>" datatype="n"  nullmsg="请填写顺序排序">
                                        <div class="help-block"></div>
                                    </div>
                                </div>
          
                                <div class="form-group ">
                                    <div class="col-sm-2 text-right">
                                        <label class="control-label Validform_label">是否显示                                        </label>
                                    </div>

                                    <div class="col-sm-10">
                                        <div id="is_privilege">
                                      
                                            <label style="color:#636f7a"><input type="radio" name="is_show" value="0" datatype="*"  nullmsg="请选择是否显示" <?=$model['is_show'] == 0?'checked="checked"':''?>>否</label>

                                            
                                            <label style="color:#636f7a"><input type="radio" name="is_show" value="1" <?=$model['is_show'] == 1?'checked="checked"':''?>>是</label>

                                                                                    </div>
                                        <div class="help-block"></div>
                                    </div>
                                </div>


     
                                <div class="form-group ">
                                    <div class='col-sm-2 text-right'>
                                        <label for="image" class="control-label Validform_label" >分类图片</label>
                                    </div>
                                    <div class='col-sm-10'>
                                        <div class="help-block"></div>
                                        <div class="test">
                                            <div class="up-button" id="select-img">选择图片</div>
                                            <div class="img-list" id="img-list">
                                                <!--图片列表样例-->
                                                <div class="img-item">
                                                    <?=showImage($model['image'])?>
                                                    <input type="hidden" name="imgs[]" />
                                                    <em class="delete" onclick="uploader.del_list(this)">×</em>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                                 </div>
                            <div class="box-footer text-center">
                                <button class="btn btn-primary" type="submit">保存</button>
                                <span class="btn btn-white" onclick="history.go(-1)">返回</span>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
{/block}

{block name="js"}
<script src="__STATIC__/admin/plugin/my_uploader/js/uploads.js"></script>
<script>

    var validate = validator('#pt_form');

    //单图上传
    $('#select-img').click(function(){
        //alert(123);
        uploader.open({
            elm:'select-img',//选择图片上传的按钮
            url:"<?=url('common/AjaxController/uploader',['path'=>'category'])?>",//服务器url
            up_type:1,//上传图片类型1:单图,2:多图
            img_list:'img-list',//存放选择图片之后的容器
            input_name:'image',//上传图片表单ID
            img_num:6,//多图上传的总数
            num:2
        });
    });
</script>
{/block}